package com.test.dao.impl;

import com.test.dao.ChoiceFullDao;
import com.test.domain.ChoiceFull;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.CallableStatementCallback;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.sql.Types;
import java.util.List;

@Repository
public class ChoiceFullDaoImpl implements ChoiceFullDao {

    @Resource
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<String> getAllMerchantPhoneNumberByCustomerPhoneNumber(String customerPhoneNumber) {

        String sql="select distinct merchant_phone_number  from V_choice where customer_phone_number=?";
        return jdbcTemplate.queryForList(sql,String.class,customerPhoneNumber);

    }

    @Override
    public List<ChoiceFull> getAllChoiceFullByCustomerPhoneNumber(String customerPhoneNumber) {
        String sql="select * from V_choice where customer_phone_number=?";
        return jdbcTemplate.query(sql,new BeanPropertyRowMapper<ChoiceFull>(ChoiceFull.class),customerPhoneNumber);
    }


}
